package company.tencent;

import java.util.*;

/**
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-16 11:22
 */
public class T3 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int t = scanner.nextInt();
            List<String> res = new ArrayList<>();
            for (int i = 0; i < t; i++) {
                int a = scanner.nextInt();
                int b = scanner.nextInt();
                int c = scanner.nextInt();

                if (helper(a,b,c))
                    res.add("YES");
                else
                    res.add("NO");
            }

            for (String s : res) {
                System.out.println(s);
            }
        }
    }


    public static boolean helper(int a,int b,int c){
        Map<Integer,Integer> map=new HashMap<>();
        int n=1;
        while (true){
            int mod=n*a%b;
            if(mod==c){
                return true;
            }else {
                if(map.containsKey(mod))
                    break;
                else
                    map.put(mod,1);
            }
            n++;
        }
        return false;
    }
}
